import { createStore, combineReducers, applyMiddleware, compose } from 'redux';
// 使得dispatch能够接收函数
import thunk from 'redux-thunk';
import reducers from './reducers';

import { h0 } from '../common/fp';
import { ORDER_DEPART } from './constant';
const state = {
    from: null, //出发城市
    to: null, //到达城市
    departDate: h0(Date.now()), //乘车日期
    highSpeed: false, //是否选择动车高铁
    trainList: [],
    orderType: ORDER_DEPART, //默认筛选类型
    onlyTickets: false, //是否只看高铁动车
    ticketTypes: [], //车票类型
    checkedTicketTypes: {}, //选中的车票类型
    trainTypes: [], //
    checkedTrainTypes: {},
    departStations: [], //始发车站
    checkedDepartStations: {}, //选中的始发车站
    arriveStations: [], //到达车站
    checkedArriveStations: {}, //选中的到达车站
    departTimeStart: 0, //发车区间的开始时间
    departTimeEnd: 24, //发车区间的结束时间
    arriveTimeStart: 0, //达到区间的开始时间
    arriveTimeEnd: 24, //到达区间的结束时间
    isFiltersVisible: false, //综合筛选浮层的显示隐藏
    searchParsed: false, // 是否解析完成服务端返回的筛选条件
};
// const store = createStore(
//   combineReducers(reducers),
//   //state的默认值
//   state,
//   applyMiddleware(thunk)
// )

const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const store = createStore(
    combineReducers(reducers),
    state,
    composeEnhancers(applyMiddleware(thunk))
);
export default store;
